package com.ermao.mymes.cron.handler;

import com.ermao.mymes.cron.service.TaskHandler;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Ermao
 * Date: 2022/5/16 14:34
 */
@Service
@Slf4j
public class CronTaskHandler {

	@Autowired
	private TaskHandler taskHandler;

	/**
	 * 简单任务
	 */
	@XxlJob("austinJob")
	public void execute() {
		log.info("CronTaskHandler#execute messageTemplateId:{} cron exec!", XxlJobHelper.getJobParam());
		Long messageTemplateId = Long.valueOf(XxlJobHelper.getJobParam());
		taskHandler.handle(messageTemplateId);
	}
}
